package com.gitee.mrj.aiboot.core.sf.generators.ui.widget.extend;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.gitee.mrj.aiboot.annotation.config.sf.ui.widget.extend.TabsetItemWidget;
import com.gitee.mrj.aiboot.core.sf.generators.FormDefinitionGenerator;
import com.gitee.mrj.aiboot.core.sf.generators.UIForm;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.stereotype.Component;

import java.lang.reflect.Field;

@Component
public class TabsetItemWidgetGenerator implements FormDefinitionGenerator {

    @Override
    public void generate(UIForm root, Field field, UIForm uiForm) {
        TabsetItemWidget arrayWidget = AnnotatedElementUtils.findMergedAnnotation(field, TabsetItemWidget.class);
        generate(uiForm, arrayWidget);
    }

    private void generate(UIForm node, TabsetItemWidget arrayWidget) {
        ObjectNode ui = node.getUi();
        ui.put("widget", "tabsetItem");
    }


    @Override
    public Class[] supports() {
        return new Class[]{TabsetItemWidget.class};
    }
}
